﻿using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Xaml;
using Microsoft.Practices.Unity;

namespace douban.Core.ViewModels
{
    public class VmLocator
    {
        private readonly IUnityContainer _unityContainer;
        public VmLocator()
        {
            _unityContainer = new UnityContainer();

            //_unityContainer.RegisterInstance(_unityContainer.Resolve<ExploreVm>());
            //_unityContainer.RegisterType<LoginVm>();
            //_unityContainer.RegisterType<ExploreVm>();
            _unityContainer.RegisterInstance(_unityContainer.Resolve<MainVm>());
            _unityContainer.RegisterInstance(_unityContainer.Resolve<TopicVm>());
            _unityContainer.RegisterInstance(_unityContainer.Resolve<CommentVm>());
            _unityContainer.RegisterType<MeVm>();
        }

        public static VmLocator Instance
        {
            get
            {
                var m = Application.Current.Resources["Locator"] as VmLocator;
                return m;
            }
        }

        public MainVm MainVm => _unityContainer.Resolve<MainVm>();
        public LoginVm LoginVm => _unityContainer.Resolve<LoginVm>();
        //public ExploreVm ExploreVm => _unityContainer.Resolve<ExploreVm>();
        public MeVm MeVm => _unityContainer.Resolve<MeVm>();

        public TopicVm TopicVm => _unityContainer.Resolve<TopicVm>();
        public CommentVm CommentVm => _unityContainer.Resolve<CommentVm>();
    }
}
